package com.briup.srms.sms.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.srms.sms.bean.GraduateApply;
import com.briup.srms.sms.bean.extend.GraduateApplyExtend;
import com.briup.srms.sms.service.IGraduateApplyService;
import com.jacky.base.utils.Message;
import com.jacky.base.utils.MessageUtil;
import com.jacky.base.utils.PageVM;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;


/**
 * @program: 杰普基础管理系统
 * @description: 离校申请控制器类
 * @author: charles
 * @create: 2020-12-27 17:22
 **/
@Api(description = "离校申请相关接口")
@Validated
@RestController
@RequestMapping("/graduateApply")
public class GraduateApplyController {
	@Autowired
	private IGraduateApplyService graduateApplyService;
	
	@ApiOperation(value = "分页多条件获取数据离校申请信息")
	@GetMapping("pageQuery")
	@ApiImplicitParams({ 
		@ApiImplicitParam(name = "page", value = "当前页", required = true, paramType = "query"),
		@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, paramType = "query"), 
		@ApiImplicitParam(name = "studentId", value = "学生编号", required = false, paramType = "query")})
	public Message pageQuery(int page, int pageSize,Long studentId) {
		PageVM<GraduateApplyExtend> pageVM = graduateApplyService.pageQuery(page, pageSize,studentId);
		return MessageUtil.success(pageVM);
	}

	@ApiOperation(value = "通过id删除")
	@ApiImplicitParams(@ApiImplicitParam(name = "id", value = "主键", paramType = "query", required = true))
	@GetMapping("deleteById")
	public Message deleteById(long id) {
		graduateApplyService.deleteById(id);
		return MessageUtil.success("删除成功");
	}

	@ApiOperation(value = "提交离校申请信息")
	@PostMapping("submit")
	public Message submit(GraduateApply graduateApply) {
		graduateApplyService.saveOrUpdate(graduateApply);
		return MessageUtil.success("提交成功");
	}
	
	@ApiOperation(value = "审核通过")
	@GetMapping("checkPass")
	public Message checkPass(Long id) {
		graduateApplyService.check(id,true);
		return MessageUtil.success("审核成功");
	}
	
	@ApiOperation(value = "审核通过")
	@GetMapping("checkReject")
	public Message checkReject(Long id) {
		graduateApplyService.check(id,false);
		return MessageUtil.success("审核成功");
	}
	
}
